using System;
using System.Runtime.Serialization;

namespace Pegasus.UnitTests.Runtime.Serialization.Formatters.Xml.XmlFormatter2Tests
{
	/// <summary>
	/// 
	/// </summary>
	[Serializable]
	public class Singleton : ISerializable, IDeserializationCallback
	{
		// Local Instance Values
		private string m_name = null;

		// Local Static Values
		private static Singleton s_instance = new Singleton();

		/// <summary>
		/// Initializes a new instance of the <see cref="T:ISerialializableSingleton"/> class.
		/// </summary>
		private Singleton()
		{
		}

		/// <summary>
		/// Gets or sets the name.
		/// </summary>
		/// <value>The name.</value>
		public string Name
		{
			get
			{
				return m_name;
			}

			set
			{
				m_name = value;
			}
		}

		/// <summary>
		/// Populates a <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> with the data needed to serialize the target object.
		/// </summary>
		/// <param name="info">The <see cref="T:System.Runtime.Serialization.SerializationInfo"></see> to populate with data.</param>
		/// <param name="context">The destination (see <see cref="T:System.Runtime.Serialization.StreamingContext"></see>) for this serialization.</param>
		/// <exception cref="T:System.Security.SecurityException">The caller does not have the required permission. </exception>
		public void GetObjectData( SerializationInfo info, StreamingContext context )
		{
			info.SetType( typeof( SingletonObjectRef ) );
		}

		/// <summary>
		/// Gets the instance.
		/// </summary>
		/// <returns></returns>
		public static Singleton GetInstance()
		{
			return s_instance;
		}

		/// <summary>
		/// Runs when the entire object graph has been deserialized.
		/// </summary>
		/// <param name="sender">The object that initiated the callback. The functionality for this parameter is not currently implemented.</param>
		public void OnDeserialization( object sender )
		{
			object a = 0;
		}
	}
}
